using System.Collections.Generic;
using System.ComponentModel;

namespace Jonathan.Classes
{
	#region -= Reference Row Comparer =-

	/// <summary>
	/// Compares two reference words  from search.
	/// </summary>
	public class RefRowComparer : IComparer<string[]>
    {
        private readonly ListSortDirection m_Direction;

		/// <summary>
		/// Create a new Reference Row Comparer
		/// </summary>
		/// <param name="direction">Sort direction.</param>
        public RefRowComparer (ListSortDirection direction)
        {
            this.m_Direction = direction;
        }

		/// <summary>
		/// Compares the given reference words.
		/// </summary>
		/// <param name="row1">First Reference</param>
		/// <param name="row2">Second Reference</param>
		/// <returns>-1,0,1 if the first reference is less than, equal, or greater than the second reference.</returns>
        public int Compare (string[] row1, string[] row2)
        {
            string book1 = row1[0];
            string book2 = row2[0];

            if (book1 != book2)
            {
                return (this.m_Direction == ListSortDirection.Ascending) ?
                            book1.CompareTo(book2) : book2.CompareTo(book1);
            }

            string word1 = row1[1];
            string word2 = row2[1];
            return (this.m_Direction == ListSortDirection.Ascending) ?
                        word1.CompareTo(word2) : word2.CompareTo(word1);
        }
	}

	#endregion

	#region -= Verse List comparer =-

	/// <summary>
	/// Compares Two verses.
	/// </summary>
	public class NewVerseListComparer : IComparer<string[]>
    {
		/// <summary>
		/// Compares the given verses.
		/// </summary>
		/// <param name="row1">First Verse.</param>
		/// <param name="row2">Second Verse.</param>
		/// <returns>-1,0,1 if the first verse is less than, equal, or greater than the second verse.</returns>
        public int Compare (string[] row1, string[] row2)
        {
            return row1[2].CompareTo(row2[2]);
        }
	}

	#endregion
}
